# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Contributor: Bartłomiej Piotrowski <nospam@bpiotrowski.pl>
# Maintainer: Bartłomiej Piotrowski <nospam@bpiotrowski.pl>
pkgname=cmus
pkgver=2.8.0
pkgrel=0
pkgdesc="A very feature-rich ncurses-based music player"
url="https://cmus.github.io/"
arch="all"
license="GPL-2.0-or-later"
options="!check" # No test suite
makedepends="alsa-lib-dev faad2-dev flac-dev libmad-dev opusfile-dev
	libogg-dev libvorbis-dev ncurses-dev wavpack-dev ffmpeg-dev
	linux-headers"
subpackages="$pkgname-doc $pkgname-zsh-completion:zshcomp:noarch
	$pkgname-bash-completion:bashcomp:noarch"
source="$pkgname-$pkgver.tar.gz::https://github.com/cmus/cmus/archive/v$pkgver.tar.gz
	c11-atomics-check.patch
	"
builddir="$srcdir"/$pkgname-$pkgver

build() {
	cd "$builddir"
	./configure prefix=/usr
	make
}

package() {
	cd "$builddir"
	make DESTDIR="$pkgdir" install

	for file in AUTHORS README.md; do
		install -Dm644 "${file}" "$pkgdir"/usr/share/doc/$pkgname/
	done
}

bashcomp() {
	depends=""
	pkgdesc="Bash completions for $pkgname"
	install_if="$pkgname=$pkgver-r$pkgrel bash-completion"

	install -Dm644 "$builddir"/contrib/$pkgname.bash-completion \
		"$subpkgdir"/usr/share/bash-completion/completions/$pkgname
}

zshcomp() {
	depends=""
	pkgdesc="Zsh completions for $pkgname"
	install_if="$pkgname=$pkgver-r$pkgrel zsh"

	install -Dm644 "$builddir"/contrib/_$pkgname \
		"$subpkgdir"/usr/share/zsh/site-functions/_$pkgname
}

sha512sums="cf359dfcefa833a5b10a2d16ac405672bea762b62b7177c115560127035682fba65c15b9a8710179a343d1f99212a0260b5c095542982202e2cd1bef5b0c17fc  cmus-2.8.0.tar.gz
97cb5e7340a9baf1d662cd965a169bf63aca28ae165bc0ca1ed81cabfd44b3d3215abbd8e8c42ecdeeaede5ca03271eccb722048d61a894b55f3c7d353e4044e  c11-atomics-check.patch"
